package ys.ewp.dto;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import ys.ewp.po.TaskParticipant;

public class TaskParticipantDto {
	//ID
	private Integer id;
	//用户ID
	private Integer employeeId;
	//任务ID
	private Integer taskId;
	//创建时间
	private Date dateCreated;
	//更新时间
	private Date dateUpdated;
	//删除标记
	private boolean deleted = false;
	
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	
	public Integer getEmployeeId() {
		return employeeId;
	}
	public void setEmployeeId(Integer employeeId) {
		this.employeeId = employeeId;
	}
	public Integer getTaskId() {
		return taskId;
	}
	public void setTaskId(Integer taskId) {
		this.taskId = taskId;
	}
	public Date getDateCreated() {
		return dateCreated;
	}
	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}
	public Date getDateUpdated() {
		return dateUpdated;
	}
	public void setDateUpdated(Date dateUpdated) {
		this.dateUpdated = dateUpdated;
	}
	public boolean isDeleted() {
		return deleted;
	}
	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}
	/**
	 * 根据用户任务Po获取用户任务Dto
	 * @param et 用户任务
	 * @return
	 */
	public static TaskParticipantDto getDtoByPo(TaskParticipant et){
		TaskParticipantDto elDto = new TaskParticipantDto();
		elDto.setId(et.getId());
		elDto.setEmployeeId(et.getEmployee().getId());
		elDto.setTaskId(et.getTask().getId());
		elDto.setDeleted(et.isDeleted());
		return elDto;
	}
	/**
	 * 根据用户任务Dto获取用户任务Po
	 * @param etDto 用户任务Dto
	 * @return
	 */
	public static TaskParticipant getPoByDto(TaskParticipantDto etDto){
		TaskParticipant et = new TaskParticipant();
		et.setId(etDto.getId());
		et.setDeleted(etDto.isDeleted());
		return et;
	}
	
	/**
	 * 	@功能 根据PO列表获取DTO列表
	 * @param taskList 
	 * @return 
	 */
	public static List<TaskParticipantDto> getDtoListByPoList(List<TaskParticipant> tpList){
		if(tpList == null || tpList.isEmpty()){
			return Collections.emptyList();
		}
		List<TaskParticipantDto> tpDtoList = new ArrayList<TaskParticipantDto>();
		for(TaskParticipant tp : tpList){
			tpDtoList.add(getDtoByPo(tp));
		}
		return tpDtoList;
	}
	/**
	 * @功能 根据DTO列表获取PO列表
	 * @param taskDtoList
	 * @return
	 */
	public static List<TaskParticipant> getPoListByDtoList(List<TaskParticipantDto> tpDtoList){
		if(tpDtoList == null || tpDtoList.isEmpty()){
			return Collections.emptyList();
		}
		List<TaskParticipant> tpList = new ArrayList<TaskParticipant>();
		for(TaskParticipantDto tpDto : tpDtoList){
			tpList.add(getPoByDto(tpDto));
		}
		return tpList;
	}
}
